home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 013 / diskpack.arc / DISKPACK.DOC next >
Encoding:
Text File  |  1986-05-02  |  19.9 KB  |  518 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                         ╔═══════════════════════════════════╗
  26.                         ║    Disk Packer - Version 1.00     ║
  27.                         ║                                   ║
  28.                         ║       Soft GAMs Software          ║
  29.                         ║       (c) Copyright 1986          ║
  30.                         ║                                   ║
  31.                         ║       G. Allen Morris III         ║
  32.                         ║       1411 10th Avenue            ║
  33.                         ║       Oakland, CA  94606          ║
  34.                         ╠═══════════════════════════════════╣
  35.                         ║    FIDO #125/521 (ALLEN MORRIS)   ║
  36.                         ║           (415)647-8528           ║
  37.                         ╚═══════════════════════════════════╝
  38.  
  39.  
  40.                                   TABLE OF CONTENTS
  41.  
  42.           INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . .    1
  43.  
  44.                                WHAT THIS PROGRAM DOES
  45.  
  46.           The idea  behind this  program is  to get  the data on your disks
  47.           into a form that DOS can read and write quickly.
  48.           The first thing that is done to speed up finding the data is that
  49.           all 'deleted'  directory entrys  are removed and the directory is
  50.           packed, that is it will have no 'deleted' entrys. Doing this will
  51.           speed up PATH search.
  52.           The next  thing to do is to de-fragment all of the data files and
  53.           to put them into  an order. There  are several  differant ways to
  54.           order the files that are listed below.
  55.  
  56.  
  57.                                 BACKGROUND PROGRAMS  . . . . . . . . .    1
  58.  
  59.           DATA LOSS  . . . . . . . . . . . . . . . . . . . . . . . . .    1
  60.  
  61.           POWER FAILURE  . . . . . . . . . . . . . . . . . . . . . . .    1
  62.  
  63.           LIMITS . . . . . . . . . . . . . . . . . . . . . . . . . . .    2
  64.  
  65.           ORGANIZING YOUR DISK . . . . . . . . . . . . . . . . . . . .    3
  66.  
  67.           RUNNING DiskPacker THE FIRST TIME  . . . . . . . . . . . . .    4
  68.  
  69.  
  70.  
  71.  
  72.  
  73.                                     INTRODUCTION
  74.  
  75.           This program started out in response to a comment that the public
  76.           domain program STUFIT would not work on DOS  3.0 or  above due to
  77.           the  way  that  MicroSoft  was  handling  the  allocation of disk
  78.           space.  In order to solve this problem I needed to use the direct
  79.           disk I/O  functions of  MSDOS and handle the updating of the file
  80.           allocation table (FAT) and  directories.  As  a result  I had the
  81.           skeleton of  a program  that could sort the data on a disk in any
  82.           order.  At this point Mark Elfield  came up  with a  algorithm to
  83.           do this  sorting and it was a simple process to implement it into
  84.           the software that I  had  written  to  move  files  to  the outer
  85.           tracks.
  86.  
  87.  
  88.                                WHAT THIS PROGRAM DOES
  89.  
  90.           The idea  behind this  program is  to get  the data on your disks
  91.           into a form that DOS can read and write quickly.
  92.           The first thing that is done to speed up finding the data is that
  93.           all 'deleted'  directory entrys  are removed and the directory is
  94.           packed, that is it will have no 'deleted' entrys. Doing this will
  95.           speed up PATH search.
  96.           The next  thing to do is to de-fragment all of the data files and
  97.           to put them into  an order. There  are several  differant ways to
  98.           order the files that are listed below.
  99.  
  100.  
  101.                                  BACKGROUND PROGRAMS
  102.  
  103.           The reason that you can not have BACKGROUND programs that read or
  104.           write the disk is that the will not be able to find were the data
  105.           on the disk is stored.  Which will cause them to read garbage and
  106.           to write to Clusters that are used by other programs.  If a write
  107.           were to  occur large amounts of data can be lost as the director-
  108.           ies can be over  written.   I  am  working  on  ways  around this
  109.           problem, but I have not come up with a good one yet.
  110.  
  111.  
  112.                                       DATA LOSS
  113.  
  114.           In  normal  operation  there  should  be  no  data loss, with the
  115.           exception of write errors that are not detected  by MSDOS  if you
  116.           have VERIFY set ON or use the /V switch. If you do not have VERFY
  117.           ON and do not  use the  /V switch  then no  write errors  will be
  118.           detected. DiskPacker will  run faster  if it  does not verify the
  119.           data, But there is a greater chance of data loss.
  120.  
  121.  
  122.                                     POWER FAILURE
  123.  
  124.  
  125.                                           1
  126.  
  127.  
  128.           In a power failure some problems can occur,  but they  can all be
  129.           fixed buy running CHKDSK and DiskPacker.
  130.  
  131.           If a  file is  being moved  there is  only a problem if the power
  132.           failure occurs between the time that the directory is written and
  133.           the FAT is written, CHKDSK and recover all of the data as it will
  134.           be in two places on the disk.  To  recover from  this run 'CHKDSK
  135.           /f' you will see the following:
  136.  
  137.           1 lost cluster found in 1 chains.
  138.           Convert lost chains to files  (Y/N)?  (Answer No)
  139.                nnnn bytes disk space freed.
  140.  
  141.           You will then get the rest of the information from CHKDSK.
  142.  
  143.           If DiskPacker  was moving  a sub-directory  then you may also see
  144.           the message:
  145.           d:\subdir\sibling
  146.                Invalid sub-directory entry.
  147.  
  148.           This message is generated if the  power failure  occurred between
  149.           writing the sub-directory and it's sibling.  You may get messages
  150.           stating  that  there  are  more  than  one  invalid sub-directory
  151.           entries.  This  is normal  as long as they all are sibling of the
  152.           same parent.
  153.  
  154.           There is only one  other problem  that can  occur and  that is if
  155.           the power  failure occurs  between the time that the first FAT is
  156.           written and the second FAT is written.  If this happens  the next
  157.           time that you run DiskPacker you will see the message:
  158.  
  159.           FATs do not compare.  (If you have not just run CHKDSK answer No)
  160.           Would you like to fix FAT2? 
  161.  
  162.           Answering Yes  to this question will write FAT1 into FAT2 and you
  163.           will be off and running.
  164.  
  165.           NOTE:
  166.           It is always important  to run  CHKDSK after  a power  failure to
  167.           correct  any  problems  that  may  have  occurred wether you were
  168.           running DiskPacker or not.
  169.  
  170.  
  171.                                        LIMITS
  172.  
  173.           Because the FAT and  directories are  read into  memory there are
  174.           some limits to there sizes.
  175.  
  176.           There must  be less than 32000 clusters on the disk.  If you have
  177.           a disk with more than 32000 clusters write me or  leave a message
  178.           on one  of the bulletin boards listed below and we can talk about
  179.           getting you a special version of DiskPacker.
  180.  
  181.                                           2
  182.  
  183.  
  184.  
  185.           There also cannot be  more than  2000 files  any one directory. -
  186.           Again if  you have this problem I can probably modify the program
  187.           to run on your disk.
  188.  
  189.           The only other limit is how much memory your computer  has limits
  190.           the total  number of  files that can be on the entire disk.  Each
  191.           directory entry takes about 34 bytes so if you have  300k of free
  192.           memory you  will be  limited to about 8000 total files before you
  193.           run out of memory.
  194.  
  195.  
  196.                                 ORGANIZING YOUR DISK
  197.  
  198.           It is hard to say what is the best way to organize  a disk  as it
  199.           will  be  different  for  each  application.   But  I will try to
  200.           describe some of the main considerations here.
  201.  
  202.           First we  need a  slight understanding  of how  MSDOS handles the
  203.           files on a disk.
  204.  
  205.           Opening a  file: When a  file is opened DOS creates a FILE handle
  206.           for the file.  The number of file handles  that can  be opened is
  207.           controlled by the FILES= command in your CONFIG.SYS file.  In the
  208.           FILE handle DOS saves information about  were the  data is stored
  209.           on the  disk.  This involves reading the directory or directories
  210.           if the file is not in the current directory and the FAT.  
  211.  
  212.           Reading from a file: When data is read from  a file  DOS looks at
  213.           the FILE handle to find the data and then reads the data into one
  214.           of the buffers that were defined in the  BUFFERS= command  in the
  215.           CONFIG.SYS file.   If this data is read again it will be read out
  216.           of this buffer and not off the disk.  
  217.  
  218.           Writing to a file: When data is  written to  a file  DOS looks to
  219.           see if the data from the location that it is going to write to is
  220.           in a buffer, if it is DOS over writes the buffer and  then writes
  221.           the data  to the  disk.  If  the data was not already in a buffer
  222.           DOS will put the data into a buffer and then write it to the disk
  223.           if this  data is then read DOS will get the data from this buffer
  224.           rather than the disk.
  225.  
  226.           Closing a file: When a file that has been written to is closed by
  227.           DOS dos  uses the  data in  the FILE  handle which was updated by
  228.           each write to update the directory entry for the file  and update
  229.           the FAT.
  230.  
  231.           We can see from this that the FAT and directory is only used when
  232.           a file is opened or closed.  Because of  this it  is not terribly
  233.           important  to  keep  the  files  on  the  outer  tracks (close to
  234.           the FAT) unless the file is opened and closed often.
  235.  
  236.  
  237.                                           3
  238.  
  239.  
  240.           So what files are opened and closed a  lot? Well Batch  files are
  241.           opened and closed between each operation.  EXE and COM files that
  242.           are simple utilities such as ASK.COM  are also  opened and closed
  243.           often.    Overlay files  are also opened and closed often, QMODEM
  244.           would run faster if it's overlay files were on the outer tracks.
  245.           Larger EXE and COM files should come after these as  they are not
  246.           opened and closed as often.
  247.  
  248.           All of these files almost never change in size and therefore will
  249.           not become fragmented this  also makes  them good  candidates for
  250.           being put on the inner tracks of the disk.  
  251.  
  252.           Many data  files are opened once read many times and then closed.
  253.           Most of the time on these files is spend reading the data  and if
  254.           there are  not enough  BUFFERS to  hold the  entire file the disk
  255.           will have to be read repeatedly.  So the location of  these files
  256.           is not  very important  but it  is important that the data in the
  257.           file is close together.  Also if the file  is used  by a database
  258.           manager  and  is  indexed  by  another file we would want both of
  259.           these files to be close together.  In some applications there may
  260.           be many  files that  are open  at the same time and we would want
  261.           all of them to be close together.
  262.  
  263.           The last  type of  file I  can think  of is  a data  file that is
  264.           written  to  often.   These  files  change  size and become frag-
  265.           mented.    Yet many  of these  files have  the same  needs as the
  266.           previous type.  If these files are placed last DiskPacker will be
  267.           able to de-fragment them  faster  and  therefore  they  should be
  268.           placed last on the disk.  
  269.  
  270.  
  271.                           RUNNING DiskPacker THE FIRST TIME
  272.  
  273.           DiskPacker has been tested with MSDOS 2.10 and MSDOS 3.00. It has
  274.           also been used on disks as big as 10 Megabytes.
  275.           There is extensive testing done to  make sure  that the  disk can
  276.           be read  and written and that the FAT and directories are in good
  277.           repair. It is very unlikely that DiskPacker will hurt the data on
  278.           your disk,  but it  is always  a good  idea to have the data on a
  279.           hard disk on BACKUP disks or tape.
  280.  
  281.           There are several ways that DiskPacker  can Optimize  the data on
  282.           your disk. They are as follows:
  283.  
  284.           Directory order.
  285.                This puts the files onto the disk in the order that they are
  286.                in the directories. You can  use the  TREE command  to get a
  287.                ruff idea of what this looks like.
  288.  
  289.           Packed order.
  290.                This leaves  the files in the same order as it finds them on
  291.  
  292.  
  293.                                           4
  294.  
  295.  
  296.                the disk. It  will leave  only one  area of  free disk space
  297.                at the outer tracks of the disk.  
  298.  
  299.           Fragmented order.
  300.                This will  put all  of the  files that are not fragmented on
  301.                the disk first and will then put the fragmented files on the
  302.                disk.  Using  this function will slowly put all of the files
  303.                that change size on  the outer  tracks of  the disk. You can
  304.                use this  function to  get a  similar effect  to the special
  305.                order function but it will take several passes  over several
  306.                days.
  307.  
  308.           Special order.
  309.                This will  let you put the files in any order that you want,
  310.                leaving free disk space where you want.
  311.  
  312.           Normally PACKED order will do everything  that you  want. And for
  313.           many user  will be  the only  DiskPacker function  that they will
  314.           use. It is also  the  default  function,  if  you  run DiskPacker
  315.           without any options this is the function it uses.
  316.  
  317.           Unless you  have a special application you are using you computer
  318.           for or you are a real speed freak you should  just run DiskPacker
  319.           with  either  the  Packed  order  or  Fragmented  order  function
  320.           switch.  
  321.  
  322.                DP /P or DP /F.
  323.  
  324.           I will go no farther with  the Directory  order function  as I do
  325.           not think  it is  of much  use and is manly included to make this
  326.           program compatible with the competition.
  327.  
  328.           Ok so you want you files to  be  just  so. You  need  to  use the
  329.           Special order function. In order to do this you will need to make
  330.           a file that lists the files in the  order that  you want  them on
  331.           the disk. Files need to have there full path names included. Sub-
  332.           directories are treated as files and not as a wild  card pointing
  333.           to all of the files in the sub-directory.
  334.           There is  also a  switch that can be included to tell Disk-Packer
  335.           where to leave free space.
  336.           The utility DPMAKE is  included to  help you  make this file. You
  337.           may also need a text editor that has a non-document mode to sort,
  338.           delete or add to this file.
  339.           The default name for this file is "DISKPACK.DPD".
  340.           And it should be in the ROOT directory  of the  disk being worked
  341.           on, or  you can  also give DiskPack the name and path of the file
  342.           you wish to use.
  343.           Below is a sample of what this file should look like.
  344.  
  345.           \COMMAND.COM             Comments can go here
  346.           \AUTOEXEC.BAT
  347.           \PROG1.OVL
  348.  
  349.                                           5
  350.  
  351.  
  352.           \PROG2.OVL
  353.           \SUBDIR_A\PROG1.OVL      This is different than \PROG1.OVL
  354.           \SUBDIR_A
  355.           \SUBDIR_B
  356.                                    All   unnamed   files   will   be  after
  357.                                    \SUBDIR_B  and  will  be  handled in the
  358.                                    in  the  same  way  as  the  Pack  order
  359.                                    function  handles  files (see above). Of
  360.                                    course if all of the files  are named in
  361.                                    this  file  there  won't be any files to
  362.                                    order.
  363.           /FREE                    This tell DiskPacker  that  the  rest of
  364.                                    the files  should be placed on the inner
  365.                                    tracks.
  366.           \CONFIG.SYS              This will be the  last file  on the disk
  367.                                    and  its  last  cluster  will occupy the
  368.                                    last cluster on the disk.
  369.           \DISKPACK.DPD            You can include this file.
  370.           \diskpack.bak            This will be  the  third  from  the last
  371.                                    file on the disk.
  372.  
  373.           As you  can see  it will  take some  work to  make this file. The
  374.           DPMAKE utility can help you make this file. Basically DPMAKE is a
  375.           WHEREIS program. The  differance is that it outputs the full path
  376.           name along with the file or  sub-directory name.   it output goes
  377.           to the standard output device.
  378.           So you can either run DPMAKE *.* and then use your text editor to
  379.           sort the data or you can run DPMAKE something like this:
  380.  
  381.           DPMAKE command.com > \diskpack.dpd
  382.           DPMAKE autoexec.bat >> \diskpack.dpd
  383.           DPMAKE *.ovl >> \diskpack.dpd
  384.           DPMAKE SUBDIR* >> \diskpack.dpd
  385.           copy con >> \DISKPACK.DPD
  386.           \FREE
  387.           ^Z
  388.           DPMAKE CONFIG.SYS >> \diskpack.dpd
  389.           DPMAKE DISKPACK.DPD >> \diskpack.dpd
  390.  
  391.           This would give you a  file  resembling  the  DISKPACK.DPD sample
  392.           above.
  393.  
  394.           DiskPacker ignores multiple file name, so this is OK:
  395.  
  396.           DPMAKE FILE*.COM >> \diskpack.dpd
  397.           DPMAKE *.COM >> \diskpack.dpd
  398.  
  399.           This  would   put  all   files  that  match  FILE????.COM  in  to
  400.           DISKPACK.DPD and then put in all the *.COM files.
  401.           SAMPLE.BAT has a sample of a good way to run DPMAKE.
  402.  
  403.           After you have gotten DISKPACK.DPD made you can run DiskPacker.
  404.  
  405.                                           6
  406.  
  407.  
  408.  
  409.           Use the following command:
  410.  
  411.                DP /S
  412.  
  413.           If you want to use a different filename  than "\DISKPACK.DPD" you
  414.           can use:
  415.  
  416.                DP /S path\filename.ext
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.                                           7
  462.  
  463.  
  464.  
  465.                                         INDEX
  466.  
  467.           /V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
  468.           BACKGROUND PROGRAMS  . . . . . . . . . . . . . . . . . . . . .  1
  469.           DATA LOSS  . . . . . . . . . . . . . . . . . . . . . . . . . .  1
  470.           DOS I/O
  471.                Closing a file  . . . . . . . . . . . . . . . . . . . . .  3
  472.                Opening a file  . . . . . . . . . . . . . . . . . . . . .  3
  473.                Reading from a file . . . . . . . . . . . . . . . . . . .  3
  474.                Writing to a file . . . . . . . . . . . . . . . . . . . .  3
  475.           DPMAKE . . . . . . . . . . . . . . . . . . . . . . . . . . . .  6
  476.           FAT  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
  477.           File allocation table  . . . . . . . . . . . . . . . . . . . .  1
  478.           INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . .  1
  479.           LIMITS . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2
  480.           ORGANIZING YOUR DISK . . . . . . . . . . . . . . . . . . . . .  3
  481.           POWER FAILURE  . . . . . . . . . . . . . . . . . . . . . . . .  1
  482.           RUNNING DiskPaker THE FIRST TIME . . . . . . . . . . . . . . .  4
  483.           VERIFY . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
  484.           WHAT THIS PROGRAM DOES . . . . . . . . . . . . . . . . . . . .  1
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.                                           8
  518.